<a href='https://github.com/angular/angular.js/edit/v1.8.x/src/ngMock/angular-mocks.js?message=docs($timeout)%3A%20describe%20your%20change...#L2294' class='improve-docs btn btn-primary'><i class="glyphicon glyphicon-edit">&nbsp;</i>Improve this Doc</a>



<a href='https://github.com/angular/angular.js/tree/v1.8.2/src/ngMock/angular-mocks.js#L2294' class='view-source pull-right btn btn-primary'>
  <i class="glyphicon glyphicon-zoom-in">&nbsp;</i>View Source
</a>


<header class="api-profile-header">
  <h1 class="api-profile-header-heading">$timeout</h1>
  <ol class="api-profile-header-structure naked-list step-list">
    
  

    <li>
      - service in module <a href="api/ngMock">ngMock</a>
    </li>
  </ol>
</header>





<div class="api-profile-description">
  <h2 id="overview">Overview</h2>
  <p>This service is just a simple decorator for <a href="api/ng/service/$timeout">$timeout</a> service
that adds a &quot;flush&quot; and &quot;verifyNoPendingTasks&quot; methods.</p>

</div>




<div>
  

  

  

  
<h2 id="$timeout-methods">Methods</h2>
<ul class="methods">
  <li>
    <h3 id="flush"><p><code>flush([delay]);</code></p>

</h3>
    <div><p>Flushes the queue of pending tasks.</p>
<p><em>This method is essentially an alias of <a href="api/ngMock/service/$flushPendingTasks"><code>$flushPendingTasks</code></a>.</em></p>
<div class="alert alert-warning">
  For historical reasons, this method will also flush non-<code>$timeout</code> pending tasks, such as
  <a href="api/ng/service/$q"><code>$q</code></a> promises and tasks scheduled via
  <a href="api/ng/type/$rootScope.Scope#$applyAsync">$applyAsync</a> and
  <a href="api/ng/type/$rootScope.Scope#$evalAsync">$evalAsync</a>.
</div></div>

    
<div class="alert alert-danger deprecation">
  <div class="title"><strong>Deprecated:</strong>
    <span class="since">(since 1.7.3) </span>
    
  </div>
  <p>This method flushes all types of tasks (not only timeouts), which is unintuitive.
It is recommended to use <a href="api/ngMock/service/$flushPendingTasks"><code>$flushPendingTasks</code></a> instead.</p>

</div>


    
    <h4>Parameters</h4>
    
<table class="variables-matrix input-arguments">
  <thead>
    <tr>
      <th>Param</th>
      <th>Type</th>
      <th>Details</th>
    </tr>
  </thead>
  <tbody>
    
    <tr>
      <td>
        delay
        
        <div><em>(optional)</em></div>
      </td>
      <td>
        <a href="" class="label type-hint type-hint-number">number</a>
      </td>
      <td>
        <p>maximum timeout amount to flush up until</p>

        
      </td>
    </tr>
    
  </tbody>
</table>

    

    

    </li>
  
  <li>
    <h3 id="verifyNoPendingTasks"><p><code>verifyNoPendingTasks();</code></p>

</h3>
    <div><p>Verifies that there are no pending tasks that need to be flushed. It throws an error if there
are still pending tasks.</p>
<p><em>This method is essentially an alias of <a href="api/ngMock/service/$verifyNoPendingTasks"><code>$verifyNoPendingTasks</code></a> (called with no
arguments).</em></p>
<div class="alert alert-warning">
  <p>
    For historical reasons, this method will also verify non-<code>$timeout</code> pending tasks, such as
    pending <a href="api/ng/service/$http"><code>$http</code></a> requests, in-progress <a href="api/ngRoute/service/$route"><code>$route</code></a> transitions, unresolved
    <a href="api/ng/service/$q"><code>$q</code></a> promises and tasks scheduled via
    <a href="api/ng/type/$rootScope.Scope#$applyAsync">$applyAsync</a> and
    <a href="api/ng/type/$rootScope.Scope#$evalAsync">$evalAsync</a>.
  </p>
  <p>
    It is recommended to use <a href="api/ngMock/service/$verifyNoPendingTasks"><code>$verifyNoPendingTasks</code></a> instead, which additionally
    supports verifying a specific type of tasks. For example, you can verify there are no
    pending timeouts with <code>$verifyNoPendingTasks(&#39;$timeout&#39;)</code>.
  </p>
</div></div>

    
<div class="alert alert-danger deprecation">
  <div class="title"><strong>Deprecated:</strong>
    <span class="since">(since 1.7.3) </span>
    
  </div>
  <p>This method takes all types of tasks (not only timeouts) into account, which is unintuitive.
It is recommended to use <a href="api/ngMock/service/$verifyNoPendingTasks"><code>$verifyNoPendingTasks</code></a> instead, which additionally
allows checking for timeouts only (with <code>$verifyNoPendingTasks(&#39;$timeout&#39;)</code>).</p>

</div>


    

    

    </li>
  </ul>
  
  



  
</div>


